package org.bigjava.novelplatform.service;

import org.bigjava.novelplatform.common.enums.CommodityType;
import org.bigjava.novelplatform.entity.Books;
import org.bigjava.novelplatform.entity.Orders;
import org.bigjava.novelplatform.entity.PurchasedChapter;
import org.bigjava.novelplatform.entity.Users;
import org.bigjava.novelplatform.vo.ChapterOrderVo;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author ykh
 * @create 2022-05-23 15:31
 */
public interface OrderService {
    Orders createOrderChapter(Integer userId, Integer commodityId, Integer counts, BigDecimal unitPrice,CommodityType type);

    @Transactional(rollbackFor={RuntimeException.class})
    void purchaseSection(Integer userId, Integer bookId, Integer sort);

    @Transactional(rollbackFor={RuntimeException.class})
    void rewardBook(Integer userId, Integer bookId, BigDecimal integral,Integer count);

    Long calculateIntegral(Integer count, BigDecimal price, Integer userId,Integer bookId ,Integer id, CommodityType type);

    BigDecimal preferentialInquiry(Users user, Books book, Integer startSort,CommodityType type);

    Boolean isFreeBookOrChapter(Integer userId, Integer bookId, Integer startSort);

    Boolean isPurchased(Integer userId, Integer bookId, Integer sort);

    Boolean isSubscribe(Integer userId, Integer bookId);

    ChapterOrderVo selectChapterOrder(Integer userId, Integer bookId, Integer chapterOrder);

    List<PurchasedChapter> queryPurchasedChapters(Integer userId, Integer bookId);

    List<PurchasedChapter> toSequenceTable(List<PurchasedChapter> plist);

    PurchasedChapter addChapter(List<PurchasedChapter> list, Integer userId, Integer bookId, Integer sort);
}
